package Averagescore;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class Tools {
    //平均分
    public static double getAvg(List<Student>stuList) {
        //所有成绩的和
        double sum=0;
        for (Student s:stuList){
            sum+=s.getScore();
        }
        return sum/stuList.size();
    }
    //获得不及格学生
    public static List<Student>getScore(List<Student>list){
        List<Student> stus=new ArrayList<>();
        Iterator<Student> it=list.iterator();
        while(it.hasNext()){
            Student stu=it.next();
            if (stu.getScore()<60){
                stus.add(stu);
            }
        }
        return stus;
    }
}

